From 0da1267457f6ce239b758dd4035ec1aec544df5a Mon Sep 17 00:00:00 2001 From: "rgr22@boulderdash.cl.cam.ac.uk" Date: Tue, 10 Jun 2003 10:28:54 +0000 Subject: [PATCH] bitkeeper revision 1.242.1.1 (3ee5b2e6yiamD8UfKwvKw39hVfWFpg) dom0_ops.h, dom0_ops.c: added CPU time to the list of values returned by a DOM0_GETDOMAININFO call dom0_core.c: added a /proc/xeno/dom/usage entry for tracking resource usage --- BitKeeper/etc/logging_ok | 1 + xen/common/dom0_ops.c | 1 + xen/include/xeno/dom0_ops.h | 1 + .../arch/xeno/drivers/dom0/dom0_core.c | 43 +++++++++++++++++++ .../arch/xeno/drivers/dom0/dom0_ops.h | 1 + 5 files changed, 47 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 90b06479c8..1af9979279 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -15,6 +15,7 @@ kaf24@plym.cl.cam.ac.uk kaf24@scramble.cl.cam.ac.uk kaf24@striker.cl.cam.ac.uk lynx@idefix.cl.cam.ac.uk +rgr22@boulderdash.cl.cam.ac.uk rn@wyvis.camb.intel-research.net rn@wyvis.research.intel-research.net smh22@boulderdash.cl.cam.ac.uk diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index c62b68b919..e54446e334 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -236,6 +236,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op) list_entry(p->pg_head.next, struct pfn_info, list) - frame_table; op.u.getdominfo.tot_pages = p->tot_pages; + op.u.getdominfo.cpu_time = p->cpu_time; } read_unlock_irqrestore(&tasklist_lock, flags); diff --git a/xen/include/xeno/dom0_ops.h b/xen/include/xeno/dom0_ops.h index 8737e192aa..93bb3e89c7 100644 --- a/xen/include/xeno/dom0_ops.h +++ b/xen/include/xeno/dom0_ops.h @@ -85,6 +85,7 @@ typedef struct dom0_getdominfo_st unsigned long mcu_advance; unsigned long pg_head; unsigned int tot_pages; + long long cpu_time; } dom0_getdominfo_t; diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c index d4777180e4..3dadd5cebd 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c @@ -55,6 +55,7 @@ typedef struct proc_mem_data { #define DOM_DIR "dom" #define DOM_MEM "mem" #define DOM_VIF "vif" +#define DOM_USAGE "usage" #define MAP_DISCONT 1 @@ -112,6 +113,39 @@ struct file_operations dom_vif_ops = { read: dom_vif_read }; +static ssize_t dom_usage_read(struct file * file, char * buff, size_t size, loff_t * off) +{ + char hyp_buf[128]; + dom0_op_t op; + static int finished = 0; + + if ( finished ) + { + finished = 0; + return 0; + } + + op.cmd = DOM0_GETDOMAININFO; + op.u.getdominfo.domain = (unsigned int) + ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data; + + (void)HYPERVISOR_dom0_op(&op); + + snprintf(hyp_buf, 128, "cpu: %lld\n", op.u.getdominfo.cpu_time); + + if (*off >= (strlen(hyp_buf) + 1)) return 0; + + copy_to_user(buff, hyp_buf, strlen(hyp_buf)); + + finished = 1; + + return strlen(hyp_buf) + 1; +} + +struct file_operations dom_usage_ops = { + read: dom_usage_read +}; + static void create_proc_dom_entries(int dom) { @@ -136,6 +170,15 @@ static void create_proc_dom_entries(int dom) file->proc_fops = &dom_vif_ops; file->data = (void *) dom; } + + file = create_proc_entry(DOM_USAGE, 0600, dir); + if (file != NULL) + { + file->owner = THIS_MODULE; + file->nlink = 1; + file->proc_fops = &dom_usage_ops; + file->data = (void *) dom; + } } static ssize_t dom_mem_write(struct file * file, const char * buff, diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h index 1a5b63dad2..8f8949a8cd 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_ops.h @@ -102,6 +102,7 @@ typedef struct dom0_getdominfo_st unsigned long mcu_advance; unsigned long pg_head; unsigned int tot_pages; + long long cpu_time; } dom0_getdominfo_t; -- 2.30.2